<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>章节目录</title>
    <link rel="stylesheet" href="fonts/iconfont.css" />
    <link rel="stylesheet" href="css/font.css" />
    <link rel="stylesheet" href="css/weui.min.css" />
    <link rel="stylesheet" href="css/jquery-weui.min.css" />
    <link rel="stylesheet" href="css/mui.css" />
    <link rel="stylesheet" href="css/pages/catemaintm.css" />

    <script>
        (function(doc, win) {
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function() {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
                };

            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);
    </script>
</head>

<body>
    <header>
        <div class="titlebar reverse">
            <a href="../index.html">
                <i class="iconfont">&#xe63f;</i>
            </a>
            <h1>考试记录</h1>
            <!-- <a href="login.html" class="app">
                <i class="iconfont">&#xe60e;</i>
            </a> -->
        </div>
    </header>
    <article style="bottom: 54px;">
        <div class="weui_cells weui_cells_access animated fadeInRight" id='app'>
            <a class="weui_cell" href="javascript:void(0)" v-for="(item,i) in dataList" @click="exam(item)">
                <div class="weui_cell_bd weui_cell_primary">
                    <p><i class="iconfont">&#xe60b;</i><strong>{{item.PAPERTITLE}}</strong></p>
                </div>
                <div class="iconfont">&#xe642;</div>
            </a>
        </div>
    </article>
    <footer>
    </footer>
</body>


<script src="../../../js/vue/vue.js"></script>
<script src="../../../js/jsCookie/js.cookie.min.js"></script>
<script src="../../../js/axios/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vant@2.12/lib/vant.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.12/lib/index.css" />





<script>
    var app = new Vue({
        el: '#app',
        data: {
            user: {},
            dataList: [],
        },
        methods: {
            getCookieUser() {
                let userJson = Cookies.get('userInfo');
                if (!userJson) {
                    this.$notify({
                        type: 'danger',
                        message: '请先登录'
                    });
                    window.location.href = '../../../../login.html'
                    return
                }
                this.user = JSON.parse(userJson)
                if (!this.user) {
                    this.$notify({
                        type: 'danger',
                        message: '请先登录'
                    });
                    window.location.href = '../../../../login.html'
                    return
                }
                this.getDataTable()
            },
            formatDate(date) {
                var date = new Date(date);
                var YY = date.getFullYear() + '-';
                var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                return YY + MM + DD + " " + hh + mm + ss;
            },
            exam(item) {
                // if (item.SCORE !== null || item.SCORE !== '') {
                //     this.$notify({
                //         type: 'danger',
                //         message: '您已经参与过这场考试！'
                //     });

                //     return
                // }
                window.location.href = 'exam2.html?pid=' + item.ID
                Cookies.set("checkItem", item, {
                    expires: 7,
                });

            },
            getDataTable() {
                let formData = new FormData();
                formData.append("userId", this.user.id);
                axios
                    .post(
                        "http://10.11.41.128:30010/exam/findExamRecore?ticket=" + Cookies.get('ticket'),
                        formData, {
                            headers: {
                                "Content-Type": "multipart/form-data",
                                "token": this.user.token,
                            },
                        }
                    )
                    .then(res => {
                        if (res.data === null || res.data === " ") return;
                        if (res.data.status === 1) {
                            console.log(res.data)
                            this.dataList = res.data.data.dataList.filter((item, index, arr) => {
                                return item.SCORE !== null
                            });

                        } else {
                            this.$notify({
                                type: 'danger',
                                message: '加载失败' + res.data.msg
                            });
                            if (res.data.msg === "未登录") {
                                window.location.href = "../../../../login.html"
                            }
                        }
                    });
            },



        },
        mounted: function() {
            this.getCookieUser()

        }
    })
</script>

</html>